package me.zhengjie.modules.fund.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.zhengjie.modules.fund.service.dto.ReqSalaryCalculate;
import me.zhengjie.modules.fund.service.dto.RespAnnualSalaryCalculate;
import me.zhengjie.modules.fund.service.PersonalSalaryCalculator;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/lifetools")
@Api(tags = "工具：薪资计算")
public class SalaryCalculateController {

    @Resource
    private PersonalSalaryCalculator salaryCalculator;

    @ApiOperation("计算月薪收入")
    @PostMapping("/salary/month")
    public ResponseEntity<Object> CalculateMonthSalary(@RequestBody ReqSalaryCalculate reqSalaryCalculate) {
        RespAnnualSalaryCalculate.MonthSalaryDetail monthSalaryDetail = salaryCalculator.CalculateMonthSalary(reqSalaryCalculate);
        return new ResponseEntity<>(monthSalaryDetail, HttpStatus.OK);
    }

    @ApiOperation("计算年薪收入")
    @PostMapping("/salary/year")
    public ResponseEntity<Object> CalculateYearSalary(@RequestBody ReqSalaryCalculate reqSalaryCalculate) {
        RespAnnualSalaryCalculate respAnnualSalaryCalculate = salaryCalculator.CalculateAnnualSalary(reqSalaryCalculate);
        return new ResponseEntity<>(respAnnualSalaryCalculate, HttpStatus.OK);
    }
}
